<!--
 * @Description: 师资队伍基本情况
 * @Autor:  'AgoniLay'
 * @Date: 2021-10-03 21:36:10
 * @LastEditTime: 2021-10-09 15:21:30
 * @FilePath: \subject-evaluation\src\views\page\2-2-1.vue
-->
<template>
  <div class="II-II-I">
    <table class="II-II-I__tableone">
      <tr class="II-II-I__tableone-trone">
        <td class="II-II-I__tableone-trone-td"
            colspan="11">
          <div class="II-II-I__tableone-trone-td-title">
            II-2 师资队伍建设质量
          </div>
        </td>
      </tr>
      <tr class="II-II-I__tableone-trtwo">
        <td class="II-II-I__tableone-trtwo-td"
            colspan="11">
          <div class="II-II-I__tableone-trtwo-td-title">
            II-2-1 师资队伍基本情况
          </div>
        </td>
      </tr>
      <tr class="II-II-I__tableone-trthree">
        <td class="II-II-I__tableone-trthree-td"
            colspan="11">
          <div class="II-II-I__tableone-trthree-td-title">
            （一）专任教师队伍结构
          </div>
        </td>
      </tr>
      <tr class="II-II-I__tableone-trfour">
        <td class="II-II-I__tableone-trfour-tdone">
          专业技术职务
        </td>
        <td v-for="(item, index) in ageList"
            :key="index + 'age'"
            class="II-II-I__tableone-trfour-tdother">
          {{ item }}
        </td>
      </tr>
      <tr v-for="(item, index) in bba.teacherStructs"
          :key="index + 1"
          class="II-II-I__tableone-trfive">
        <td class="II-II-I__tableone-trfive-tdone">
          {{ item.post }}
        </td>
        <td class="II-II-I__tableone-trfive-tdother">
          <el-input v-model="item.total"
                    readonly
                    type="number"/>
        </td>
        <td class="II-II-I__tableone-trfive-tdother">
          <el-input v-model="item.thirtyFive"
                    :readonly="index === 4"
                    type="number"/>
        </td>
        <td class="II-II-I__tableone-trfive-tdother">
          <el-input v-model="item.fortyFive"
                    :readonly="index === 4"
                    type="number"/>
        </td>
        <td class="II-II-I__tableone-trfive-tdother">
          <el-input v-model="item.fiftyFive"
                    :readonly="index === 4"
                    type="number"/>
        </td>
        <td class="II-II-I__tableone-trfive-tdother">
          <el-input v-model="item.sixty"
                    :readonly="index === 4"
                    type="number"/>
        </td>
        <td class="II-II-I__tableone-trfive-tdother">
          <el-input v-model="item.sixtyOne"
                    :readonly="index === 4"
                    type="number"/>
        </td>
        <td class="II-II-I__tableone-trfive-tdother">
          <el-input v-model="item.doctorNum"
                    :readonly="index === 4"
                    type="number"/>
        </td>
        <td class="II-II-I__tableone-trfive-tdother">
          <el-input v-model="item.abroadNum"
                    :readonly="index === 4"
                    type="number"/>
        </td>
        <td class="II-II-I__tableone-trfive-tdother">
          <el-input v-model="item.doctorTutor"
                    :readonly="index === 4"
                    type="number"/>
        </td>
        <td class="II-II-I__tableone-trfive-tdother">
          <el-input v-model="item.masterGuide"
                    :readonly="index === 4"
                    type="number"/>
        </td>
      </tr>
    </table>
    <!-- 学缘结构 -->
    <table class="II-II-I__tabletwo">
      <tr class="II-II-I__tabletwo-trone">
        <td class="II-II-I__tabletwo-trone-tdone"
            rowspan="2">
          学缘<br>结构
        </td>
        <td class="II-II-I__tabletwo-trone-tdtwo">
          最高学位获得单位<br>
          <span class="II-II-I__tabletwo-trone-tdtwo-tips">
            (人数最多的5所)
          </span>
        </td>
        <td v-for="(item, index) in bba.schoolStructs"
            :key="index"
            class="II-II-I__tabletwo-trone-tdother">
          <el-input v-model="item.schoolName"
                    type="textarea"
                    placeholder="XX大学"
                    autosize
                    class="II-II-I__tabletwo-trone-tdother-input"/>
        </td>
      </tr>
      <tr class="II-II-I__tabletwo-trtwo">
        <td class="II-II-I__tabletwo-trtwo-tdone">
          人数及比例
        </td>
        <td v-for="(item, index) in bba.schoolStructs"
            :key="index"
            class="II-II-I__tabletwo-trtwo-tdother">
          <el-input v-model="item.stuNum"
                    type="text"
                    placeholder="23"
                    class="II-II-I__tabletwo-trtwo-tdother-input">
            <template slot="append">
              ({{ item.ratio }}%)
            </template>
          </el-input>
        </td>
      </tr>
    </table>
    <!-- 生师比 -->
    <table class="II-II-I__tablethree">
      <tr class="II-II-I__tablethree-trone">
        <td class="II-II-I__tablethree-trone-tdone"
            rowspan="2">
          生师比
        </td>
        <td class="II-II-I__tablethree-trone-tdtwo">
          在校博士生数
        </td>
        <td class="II-II-I__tablethree-trone-tdthree">
          <el-input v-model="bba.doctorStuNum"
                    type="number"
                    class="II-II-I__tablethree-trone-tdthree-input"/>
        </td>
        <td class="II-II-I__tablethree-trone-tdfour">
          在校硕士生数
        </td>
        <td class="II-II-I__tablethree-trone-tdfive">
          <el-input v-model="bba.masterStuNum"
                    type="number"
                    class="II-II-I__tablethree-trone-tdfive-input"/>
        </td>
      </tr>
      <tr class="II-II-I__tablethree-trtwo">
        <td class="II-II-I__tablethree-trtwo-tdone">
          专任教师生师比
        </td>
        <td class="II-II-I__tablethree-trone-tdtwo">
          <el-input v-model="bba.fullTimeRatio"
                    type="text"
                    class="II-II-I__tablethree-trone-tdtwo-input"/>
        </td>
        <td class="II-II-I__tablethree-trone-tdthree">
          研究生导师生师比
        </td>
        <td class="II-II-I__tablethree-trone-tdfour">
          <el-input v-model="bba.graduateTutorRatio"
                    type="text"
                    class="II-II-I__tablethree-trone-tdfour-input"/>
        </td>
      </tr>
      <tr class="II-II-I__tablethree-trthree">
        <td class="II-II-I__tablethree-trthree-td"
            colspan="5">
          <div class="II-II-I__tablethree-trthree-td-title">
            （二）其他教师队伍和教师团队情况
            <span class="II-II-I__tablethree-trthree-td-title-tips">
              （限300字）<br>填写兼职教师、柔性引进人员、短期人才项目等其他教师队伍和教师团队基本情况。
            </span>
          </div>
        </td>
      </tr>
      <tr class="II-II-I__tablethree-trfour">
        <td class="II-II-I__tablethree-trfour-td"
            colspan="5">
          <el-input v-model="bba.otherInfo"
                    type="textarea"
                    maxlength="300"
                    showWordLimit
                    placeholder="请输入其他教师队伍和教师团队情况"
                    :autosize="{ minRows : 3 }"
                    class="II-II-I__tablethree-trfour-td-textarea"/>
        </td>
      </tr>
    </table>
    <!-- 说明 -->
    <div class="II-II-I__explain">
      <span class="II-II-I__explain-strong">
        说明：①
      </span>
      本表填写2020年12月31日的师资队伍基本情况。
      <span class="II-II-I__explain-strong">
        ②
      </span>
      专任教师指人事关系在本单位（包括仅与本单位签署全职工作合同的聘用制人员），且具有教师资格、专门从事教学工作的人员，不含教辅人员、博士后及2020年12月31日前已退休或去世人员；直属附属医院中具有副高级及以上职称或具有高等学校教师资格，且承担教学工作的临床教师可计入专任教师。
      <span class="II-II-I__explain-strong">
        ③
      </span>
      跨学科人员统计在“主要学科”，不在多个学科重复统计。
      <span class="II-II-I__explain-strong">
        ④
      </span>
      所有“年龄”均按周岁统计，下同。
      <span class="II-II-I__explain-strong">
        ⑤
      </span>
      “具有境外经历”指在境外机构获得学位或从事教学、科研工作时间连续超过10个月。
      <span class="II-II-I__explain-strong">
        ⑥
      </span>
      “博导人数”仅统计评估期内实际指导博士生的导师人数；“硕导人数”仅统计评估期内实际指导硕士生的导师人数，不包括“博导”。
      <span class="II-II-I__explain-strong">
        ⑦
      </span>
      在校博士生数与硕士生数统计具有学籍并在本学年9月1日进行学籍注册的全日制研究生，不含同等学力申请博士和硕士人员；计算生师比时，博士生数与硕士生数按1.5:1进行折算，如“研究生导师生师比”=（在校博士生数×1.5+在校硕士生数）/（博导人数+硕导人数）。
    </div>
  </div>
</template>

<script>
import { getPageData } from '@/utils/getData.js'

export default {
  watch: {
    bba: {
      handler (newVal) {
        sessionStorage['this_data'] = JSON.stringify(newVal)
      },
      deep: true,
      immediate: true
    },
    'bba.schoolStructs': {
      handler (newVal) {
        var total = this.getSum(newVal, 'stuNum')
        for (let i = 0, len = newVal.length; i < len; i++) {
          this.bba.schoolStructs[i].ratio = this.getRatio(total, this.bba.schoolStructs[i].stuNum)
        }
      },
      deep: true,
      immediate: true
    },
    'bba.teacherStructs': {
      handler (newVal) {
        this.allAgeDataList.forEach(item => {
          this.bba.teacherStructs[4][item] = this.getSum(newVal.slice(0, 4), item)
        })
      },
      deep: true,
      immediate: true
    },
    'bba.teacherStructs.0': {
      handler (newVal) {
        let total = 0
        this.ageDataList.forEach(item => {
          total += Number(newVal[item])
        })
        this.bba.teacherStructs[0].total = total
      },
      deep: true,
      immediate: true
    },
    'bba.teacherStructs.1': {
      handler (newVal) {
        let total = 0
        this.ageDataList.forEach(item => {
          total += Number(newVal[item])
        })
        this.bba.teacherStructs[1].total = total
      },
      deep: true,
      immediate: true
    },
    'bba.teacherStructs.2': {
      handler (newVal) {
        let total = 0
        this.ageDataList.forEach(item => {
          total += Number(newVal[item])
        })
        this.bba.teacherStructs[2].total = total
      },
      deep: true,
      immediate: true
    },
    'bba.teacherStructs.3': {
      handler (newVal) {
        let total = 0
        this.ageDataList.forEach(item => {
          total += Number(newVal[item])
        })
        this.bba.teacherStructs[3].total = total
      },
      deep: true,
      immediate: true
    },
    'bba.teacherStructs.4': {
      handler (newVal) {
        let total = 0
        this.ageDataList.forEach(item => {
          total += Number(newVal[item])
        })
        this.bba.teacherStructs[4].total = total
      },
      deep: true,
      immediate: true
    }
  },
  async mounted () {
    const loading = this.$loading({ lock: true, text: '数据获取中...请稍后！', background: 'rgba(0, 0, 0, 0.7)' })

    this.bba = await getPageData('bba')
    if (this.bba.schoolStructs) {
      for (let i = this.bba.schoolStructs.length; i < 5; i++) {
        this.bba.schoolStructs.push({ schoolName: '', stuNum: '', ratio: '' })
      }
    }
    loading.close()
  },
  data () {
    return {
      ageList: ['合计', '35岁及以下', '36至45岁', '46至55岁', '56至60岁', '60岁及以上', '博士学位人数', '具有境外经历人数', '博导人数', '硕导人数'],
      ageDataList: ['thirtyFive', 'fortyFive', 'fiftyFive', 'sixty', 'sixtyOne'],
      allAgeDataList: ['thirtyFive', 'fortyFive', 'fiftyFive', 'sixty', 'sixtyOne', 'doctorNum', 'abroadNum', 'doctorTutor', 'masterGuide'],
      bba: {
        teacherStructs: [
          { post: '正高级', total: 0, thirtyFive: '', fortyFive: '', fiftyFive: '', sixty: '', sixtyOne: '', doctorNum: '', abroadNum: '', doctorTutor: '', masterGuide: '' },
          { post: '高级', total: 0, thirtyFive: '', fortyFive: '', fiftyFive: '', sixty: '', sixtyOne: '', doctorNum: '', abroadNum: '', doctorTutor: '', masterGuide: '' },
          { post: '中级', total: 0, thirtyFive: '', fortyFive: '', fiftyFive: '', sixty: '', sixtyOne: '', doctorNum: '', abroadNum: '', doctorTutor: '', masterGuide: '' },
          { post: '其他', total: 0, thirtyFive: '', fortyFive: '', fiftyFive: '', sixty: '', sixtyOne: '', doctorNum: '', abroadNum: '', doctorTutor: '', masterGuide: '' },
          { post: '总计', total: 0, thirtyFive: 0, fortyFive: 0, fiftyFive: 0, sixty: 0, sixtyOne: 0, doctorNum: 0, abroadNum: 0, doctorTutor: 0, masterGuide: 0 }
        ],
        schoolStructs: [
          { schoolName: '', stuNum: '', ratio: '' },
          { schoolName: '', stuNum: '', ratio: '' },
          { schoolName: '', stuNum: '', ratio: '' },
          { schoolName: '', stuNum: '', ratio: '' },
          { schoolName: '', stuNum: '', ratio: '' }
        ],
        doctorStuNum: '',
        masterStuNum: '',
        fullTimeRatio: '',
        graduateTutorRatio: '',
        otherInfo: ''
      },
      this_total: 0
    }
  },
  methods: {
    getSum (arr, str) {
      var sum = 0
      if (str) {
        for (let i = 0; i < arr.length; i++) {
          if (arr[i][str] === '') sum += 0
          else sum += parseInt(Number(arr[i][str]))
        }
      } else {
        for (let i = 0; i < arr.length; i++) {
          if (arr[i] === '') sum += 0
          else sum += parseInt(Number(arr[i]))
        }
      }
      return sum
    },
    getRatio (all, part) {
      let ratio = '0'
      if (all && part) {
        ratio = (part / all * 100).toFixed(1)
      }
      return ratio
    }
  }
}
</script>

<style lang="less" scoped>
@import '../../assets/css/page/2-2-1.less';
</style>
